    Date.prototype.setISO8601 = function (string) {
    var regexp = "([0-9]{4})(-([0-9]{2})(-([0-9]{2})" +
        "(T([0-9]{2}):([0-9]{2})(:([0-9]{2})(\.([0-9]+))?)?" +
        "(Z|(([-+])([0-9]{2}):([0-9]{2})))?)?)?)?";
    var d = string.match(new RegExp(regexp));

    var offset = 0;
    var date = new Date(d[1], 0, 1);

    if (d[3]) { date.setMonth(d[3] - 1); }
    if (d[5]) { date.setDate(d[5]); }
    if (d[7]) { date.setHours(d[7]); }
    if (d[8]) { date.setMinutes(d[8]); }
    if (d[10]) { date.setSeconds(d[10]); }
    if (d[12]) { date.setMilliseconds(Number("0." + d[12]) * 1000); }
    if (d[14]) {
        offset = (Number(d[16]) * 60) + Number(d[17]);
        offset *= ((d[15] == '-') ? 1 : -1);
    }

    offset -= date.getTimezoneOffset();
    time = (Number(date) + (offset * 60 * 1000));
    this.setTime(Number(time));
}
function getHealth(speed)
{
    var cur=parseInt(speed*10)
    if(cur==0)
    {
        return 0;
    }
    else
    {
        return parseInt(10*Math.log(cur));
    }
}
function gettimediff(isotime)
{
    var d1=new Date();
    var d2 = new Date();
    d2.setISO8601(isotime);
    var convert=24*60*60*1000;
    var d=(d1-d2)/convert;
    return d;
}
        function cbfunc(res)
        {
           if(res.query.count>0)
           {
                var d1=new Date();
                var d2 = new Date();
                var speed_max=0;
                if(res.query.count>1)
                {
                  
                    for(var i=0;i<res.query.count;i++)
                    {
                        var cur_speed=(i+1)/gettimediff(res.query.results.span[i].title);
                        if(speed_max<cur_speed)
                        {
                            speed_max=cur_speed;
                        }
                    }
                }
                else if(res.query.count==1)
                {
                    speed_max=1/gettimediff(res.query.results.span.title);
                    //d2.setISO8601(res.query.results.span.title);
                }
                var div=document.getElementById("SPEED");
                var user_img=document.createElement("img");
                var username=res.query.diagnostics.url.content;
                var twitter_url="http://twitter.com/";
                username=username.substring(twitter_url.length);
                var link="<"+"a href=\""+res.query.diagnostics.url.content+"\">"+username+"<"+"/a>";
                var link_me="<"+"a href=\""+"http://www.tweetactive.com"+"\">"+"http://www.tweetactive.com"+"<"+"/a>";
                
                div.innerHTML="<STRONG>I am "+link+" my TweetActive Index is "+getHealth(speed_max)+"</STRONG><br>"+link_me;
               
           }
        }